import requests
from camel.agents import ChatAgent
from camel.models import ModelFactory
from camel.types import ModelPlatformType
from camel.messages import BaseMessage
from camel.types import RoleType
from PIL import Image
from io import BytesIO
from dotenv import load_dotenv
import os
load_dotenv()
import os
Model_Type=os.getenv("MODEL_TYPE")
Model_Api=os.getenv("ZHIPU_API_KEY")
Model_Url=os.getenv("MODEL_URL")
model = ModelFactory.create(
    model_platform=ModelPlatformType.OPENAI,
    model_type=Model_Type,
    api_key=Model_Api,
    url=Model_Url
)
agent = ChatAgent(
    model=model,
    output_language='中文'
)

msg = BaseMessage(
    role_name='User1',
    role_type=RoleType.USER,
    content='你好，为我列举一下中国的主要城市，给出名称即可',
    meta_dict={}
)
msg2=BaseMessage(
    role_name='User1',
    role_type=RoleType.USER,
    content='详细讲解第二个城市',
    meta_dict={}
)
msg3=BaseMessage(
    role_name='User1',
    content="刚才一共列举了几个城市？",
    meta_dict={},
    role_type=RoleType.USER,
)
response = agent.step(msg)
response2 = agent.step(msg2)
response3 = agent.step(msg3)
print(f"{msg.role_name}:",response.msgs[0].content)
print(response2.msgs[0].content)
print(response3.msgs[0].content)